<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>Document</title>
</head>

<body>
    <h1>复习ES6常用语法</h1>
    <script>
        const data1 = [
            {
                id: 1,
                goods_name:
                    '班俏BANQIAO超火ins潮卫衣女士2020秋季新款韩版宽松慵懒风薄款外套带帽上衣',
                goods_img: 'https://www.escook.cn/vuebase/pics/1.png',
                goods_price: 108,
                goods_count: 1,
                goods_state: true,
                info: {
                    // 颜色
                    color: '白色',
                    // 尺码
                    size: 'L码',
                    // 剩余件数
                    left: 36,
                },
            },
            {
                id: 2,
                goods_name:
                    '嘉叶希连帽卫衣女春秋薄款2020新款宽松bf韩版字母印花中长款外套ins潮',
                goods_img: 'https://www.escook.cn/vuebase/pics/2.png',
                goods_price: 129,
                goods_count: 1,
                goods_state: true,
                info: {
                    // 颜色
                    color: '藏青色',
                    // 尺码
                    size: 'M码',
                    // 剩余件数
                    left: 19,
                },
            },
        ]

        // 解构赋值
        // 需求：解构出data1数组中的对象
        const [obj1, obj2] = data1
        console.log(obj1, obj2);
        // 需求：解构出第一件商品的 goods_name 、 goods_price 、goods_count
        const { goods_name, goods_price, goods_count } = obj1
        console.log(goods_name);

        // 需求：解构出第二件商品的 color、size, left 数据
        const { info: { color, size, left: leftCount } } = obj2
        console.log(color);

        // 展开运算符 
        // 需求：将 data1 和 data2 进行拼接成一个数组
        const data2 = [
            {
                id: 3,
                goods_name: '思蜜怡2020休闲运动套装女春秋季新款时尚大码宽松长袖卫衣两件套',
                goods_img: 'https://www.escook.cn/vuebase/pics/3.png',
                goods_price: 198,
                goods_count: 1,
                goods_state: false,
            },
            {
                id: 4,
                goods_name: '思蜜怡卫衣女加绒加厚2020秋冬装新款韩版宽松上衣连帽中长款外套',
                goods_img: 'https://www.escook.cn/vuebase/pics/4.png',
                goods_price: 99,
                goods_count: 1,
                goods_state: false,
            },
        ]


        // 对象方法简写
        const newArr = [...data1, ...data2]
        console.log(newArr);

    </script>
</body>

</html>